#include <stdio.h>
#include<stdlib.h>
#include <assert.h>
struct ListNode
{
    int data;
    struct ListNode*next;
};
struct ListNode* middle(struct ListNode*head)
{
    assert(head);
    struct ListNode*fast=head;
    struct ListNode*slow=head;
    while(fast&&fast->next)
    {
        fast=fast->next->next;
        slow=slow->next;
    }

    if(head==NULL)
    {
        return NULL;
    }
    return slow;
}
int main()
{
    struct ListNode*n1= (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode*n2= (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode*n3= (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode*n4= (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode*n5= (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode*n6= (struct ListNode*)malloc(sizeof(struct ListNode));

    n1->data=1;
    n2->data=2;
    n3->data=3;
    n4->data=4;
    n5->data=5;
    n6->data=6;


    n1->next=n2;
    n2->next=n3;
    n3->next=n4;
    n4->next=n5;
    n5->next=n6;
    n6->next=NULL;
    struct ListNode*ret=middle(n1);
}
